package com.qyhl.webtv.module_news.luckydraw.fragment;


import com.qyhl.webtv.commonlib.entity.news.LuckDrawInfoBean;
import com.qyhl.webtv.commonlib.entity.news.LuckDrawLiveBean;
import com.qyhl.webtv.commonlib.entity.news.LuckDrawPhaseBean;
import com.qyhl.webtv.commonlib.entity.news.NewsBean;

import java.util.List;

/**
 * Created by Administrator on 2018/6/8.
 */

public class LuckDrawFragmentPresenter implements LuckDrawFragmentContract.LuckDrawPresenter {
    private LuckDrawFragmentModel mModel;
    private LuckDrawFragment mView;

    LuckDrawFragmentPresenter(LuckDrawFragment mView) {
        this.mView = mView;
        this.mModel = new LuckDrawFragmentModel(this);
    }

    @Override
    public void getTop(String sections) {
        mModel.getTop(sections);
    }

    @Override
    public void getLive(String catalogId, String type) {
        mModel.getLive(catalogId, type);
    }

    @Override
    public void setTop(boolean isShow, List<NewsBean> beanList) {
        mView.setTop(isShow, beanList);
    }

    @Override
    public void setLive(List<LuckDrawLiveBean> beanList) {
        boolean isShow = true;
        if (beanList == null || beanList.get(0) == null || beanList.get(0).getMenuLive() == null) {
            isShow = false;
        }
        mView.setLive(isShow, beanList);
    }

    @Override
    public void getPhase() {
        mModel.getPhase();
    }

    @Override
    public void queryInfo(String phoneNum) {
        mModel.queryInfo(phoneNum);
    }

    @Override
    public void queryTicketInfo(String phoneNum) {
        mModel.queryTicketInfo(phoneNum);
    }

    @Override
    public void setQueryInfoSuccess(boolean isWinner, List<LuckDrawInfoBean> beanList) {
        mView.setQueryInfoSuccess(isWinner, beanList);
    }


    @Override
    public void setQueryInfoError(int code, String msg) {
        switch (code) {
            case 0:
                mView.setQueryInfoError(msg);
                break;
            case 1:
                mView.setQueryInfoError(msg);
                break;
            default:
                mView.setQueryInfoError("查询失败！");
                break;
        }
    }

    @Override
    public void queryTicketInfoSuccess(List<LuckDrawInfoBean> beanList) {
        mView.queryTicketInfoSuccess(beanList);
    }

    @Override
    public void queryTicketInfoError(int code, String msg) {
        switch (code) {
            case 0:
                mView.queryTicketInfoError(msg);
                break;
            case 1:
                mView.queryTicketInfoError(msg);
                break;
            default:
                mView.queryTicketInfoError("查询失败！");
                break;
        }
    }

    @Override
    public void setPhase(LuckDrawPhaseBean bean) {
        mView.setPhase(bean);
    }

    @Override
    public void setPhaseError(int code, String msg) {
        mView.setPhaseError(msg);
    }

    @Override
    public void commitInfo(String code, String codeNum, String sum, String date, String phoneNum, String businessName) {
        mModel.commitInfo(code, codeNum, sum, date, phoneNum, businessName);
    }

    @Override
    public void commentResult(boolean isSuccess, String msg) {
        mView.commentResult(isSuccess, msg);
    }
}
